package gja;

import static org.junit.Assert.assertEquals;
import robocode.control.testing.RobotTestBed;
import robocode.BattleResults;
import robocode.control.events.BattleCompletedEvent;

/**
 * TestShootNScootFire verifies if ShootNScoot beats SittingDuck.
 * 
 * @author Philip Johnson
 * @author Jayson Gamiao
 */
public class TestShootNScootSittingDuck extends RobotTestBed {

  /**
   * Specifies that SittingDuck and ShootNScoot are to be matched up in this test case.
   * 
   * @return The comma-delimited list of robots in this match.
   */
  @Override
  public String getRobotNames() {
    return "sample.SittingDuck,gja.ShootNScoot";
  }

  /**
   * This test runs for 10 rounds.
   * 
   * @return The number of rounds.
   */
  @Override
  public int getNumRounds() {
    return 10;
  }

  /**
   * The actual test, which asserts that ShootNScoot has won every round against SittingDuck.
   * 
   * @param event Details about the completed battle.
   */
  @Override
  public void onBattleCompleted(BattleCompletedEvent event) {
    // Return the results in order of getRobotNames.
    BattleResults[] battleResults = event.getIndexedResults();
    // Sanity check that results[1] is ShootNScoot (not strictly necessary,
    // but illustrative).
    BattleResults shootNScootResults = battleResults[1];
    String robotName = shootNScootResults.getTeamLeaderName();
    assertEquals("Check that results[1] is ShootNScoot", robotName, "gja.ShootNScoot*");

    // Check to make sure ShootNScoot won every round.
    assertEquals("Check ShootNScoot winner", shootNScootResults.getFirsts(), getNumRounds());
  }
}